package com.intellekt.ecert.connection.action;

import static com.intellekt.ecert.domain.Constantes.USUARIO;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.apache.struts2.interceptor.SessionAware;
import org.springframework.beans.factory.annotation.Autowired;

import com.intellekt.ecert.connection.service.ConnectionsService;
import com.intellekt.ecert.domain.CatalogoVO;
import com.intellekt.ecert.domain.DomainActionSupport;
import com.intellekt.ecert.domain.UsuarioVO;

@Results( { @Result(name = "input", location = "connections", type = "tiles") })
public class ConnectionsAction extends DomainActionSupport implements SessionAware{

    
    /**
     * 
     */
    private static final long serialVersionUID = 7827513005592727263L;
    
    private static final Logger log = Logger.getLogger(ConnectionsAction.class);
    
    protected Map<String, Object> session;
    
    @Autowired
    private ConnectionsService service;
    
    private List<CatalogoVO> countries;
    
    @Override
    public String getActionId() {
        return "connections";
    }

    public void setSession(Map<String, Object> session) {
        this.session = session;
    }

    @Override
    public String input() throws Exception {
        if (log.isInfoEnabled()) {
            log.info("input Connections...");
        }
        
        countries = service.getCountries();
        String verify = super.verificar(this.getActionId(), (UsuarioVO) session.get(USUARIO));
        if (verify != null) {
            return verify;
        }
       
        
        return INPUT;
    }

	public List<CatalogoVO> getCountries() {
		return countries;
	}

    
}
